<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>MKTB15</TITLE>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<LINK href="../css/IDEA.css" type=text/css rel=stylesheet>
<SCRIPT language=javascript src="../js/IDEA_body.js"
	type=text/javascript></SCRIPT>
<link rel="stylesheet" type="text/css" href="../js/window/skin/qq/ymPrompt.css" />
<SCRIPT language=javascript src="../js/window/ymPrompt_Ex.js" type=text/javascript></SCRIPT>
<SCRIPT language=javascript src="../js/window/ymPrompt_source.js" type=text/javascript></SCRIPT>
<SCRIPT language=javascript src="../js/ajax.js" type=text/javascript></SCRIPT>
<script type="text/javascript">
 ymPrompt.setDefaultCfg({winAlpha:'1.0',maskAlpha:'0.1',maskAlphaColor:'#00f'});
 function openwin()
 {
    	var systemId = document.getElementById("systemId").value;
    	ymPrompt.win({message:'../station/queryRoleInfo.html?systemId='+systemId,width:800,height:400,title:'角色信息查询',iframe:true});
    
 } 
 var strId = new Array();
 var strName = new Array();  
 
 function openService()
 {
	 ymPrompt.win({message:'../station/querySystemInfo.html',width:800,height:400,title:'子系统信息查询',iframe:true});
 }
 var systemId='';
 function setSystemValue(systemValue)
 {  
    var info = systemValue.split(",");
    systemId = document.getElementById("systemId").value;
    if(systemId != info[0])
    {
       document.getElementById("systemName").value=info[1];  
       document.getElementById("systemId").value=info[0];
       document.getElementById("roleId").value='';
       document.getElementById('roleName').value='';  
       systemId = document.getElementById("systemId").value;
    }
    return;
 }
 
 function setValue(strId,strName)
 {
    var roleId='';
     var roleName ='';
     if(null != strId && 0 != strId.length)
     {
         for(var i = 0; i < strId.length; i++)
         {
             roleId+=strId[i]+",";
         }
     }
      if(null != strName && 0 != strName.length)
     {
         for(var j = 0; j < strName.length; j++)
         {
             roleName+=strName[j]+",";
         }
     }
     
     document.getElementById("roleId").value= roleId.substr(0,roleId.length-1);
     
     document.getElementById('roleName').value= roleName.substr(0,roleName.length-1);
                  
     return;
 }
 
 function saveValue(roleId,roleName)
 {      
     var flag = false;
        
      if(null != roleId)
      {     
        if(null != strId && 0 != strId.length)
        {
           for(var i = 0; i < strId.length; i++)
           {
               if(strId[i] == roleId)
               {
                  flag = true;   
               }
           }          
        }
        if(!flag)
        {
            strId.push(roleId); 
        } 
      }
      if(null != roleName )
      {
        flag = false;
        
        if(null != strName && 0 != strName.length)
        {
            for(var j = 0; j < strName.length; j++)
            {
                if(strName[j] == roleName)
                {
                    flag = true;   
                }
            }
        }      
        if(!flag)
        {
           strName.push(roleName); 
        }
      
      }
    setValue(strId,strName);
 }
 
 function delValue(roleId,roleName)
 {      
      if(null != roleId)
      {
         if(null != strId && 0 != strId.length)
         {
             for(var i = 0; i < strId.length; i++)
             {
                if(roleId == strId[i])
                {
                    strId.splice(i,1);                   
                }
             }
         }       
      }
      if(null != roleName)
      {
         if(null != strName && 0 != strName.length)
         {
             for(var j = 0; j < strName.length; j++)
             {
                if(roleName == strName[j])
                {
                    strName.splice(j,1);
                }
             }
         }        
      }
      
    setValue(strId,strName);        
 }
 
 function validate(myform)
 {
    if(myform.getAttribute("stationName").value=='')
    {
        alert('请输入岗位名称');  
        
        return false;
    }
    if(myform.getAttribute("systemId").value=='')
    {
        alert("请选择业务系统");
        
        return false;
    }
    if(myform.getAttribute("roleId").value=='')
    {
        alert("请选择角色");
        
        return false;
    }
    
    if(myform.getAttribute("isExist").value!="0")
    {
        alert("岗位名称已存在");
        
        return false;
    }
    
 }
    function checkStationName(obj)
    {
    	if(obj.value!="")
    	{
    		var url = "../station/checkStationName.html?stationName="+encodeURIComponent(encodeURIComponent(obj.value));
    		sendRequest1(url);
    	}
    }
  //发送请求函数
	function sendRequest1(url) {
		createXMLHttpRequest();
		XMLHttpReq.open("GET", url, true);
		XMLHttpReq.onreadystatechange = processResponse1;//指定响应函数
		XMLHttpReq.send(null);  // 发送请求
	}
	// 处理返回信息函数
     function processResponse1() {
	    if (XMLHttpReq.readyState == 4) 
	    {

	        var isExist = XMLHttpReq.responseText;
	        if(isExist!="0")
	        {
	        	document.getElementById("errMsg").innerHTML="岗位名称已存在";
	        	document.getElementById("isExist").value=isExist;
	        }
	        else
	        {
	        	document.getElementById("errMsg").innerHTML="";
	        	document.getElementById("isExist").value=isExist;
	        }
        }
    }
 
</script>
<META content="MSHTML 6.00.2900.3243" name=GENERATOR>
</HEAD>
<BODY>
<form name="myform" method="POST"
	action="../station/addStationInfo.html" onsubmit="return validate(this);">
<TABLE width="100%" height="100%" border=0 cellPadding=0 cellSpacing=0>
	<form name="myform" method="POST"
		action="../station/modifyStationInfo.html" 	onsubmit="return validate(this);">
	<TBODY>
		<TR>
			<TD height="100%" bgcolor="#FFFFFF" class=right_bg>
			<table width="100%" height="5" border="0" cellpadding="0"
				cellspacing="0">
				<tr>
					<td></td>
				</tr>
			</table>
			<table width="100%" border="0" align="center" cellpadding="0"
				cellspacing="0">
				<tr>
					<td width="20">&nbsp;</td>
					<td class="text_12_title">当前位置: <a href="#" class="blue_1">首页</a>&gt;
					<a href="#">权限管理</a> &gt; <a href="#">修改岗位信息</a>
				</tr>
			</table>
			<table width="100%" height="10" border="0" cellpadding="0"
				cellspacing="0">
				<tr>
					<td></td>
				</tr>
			</table>
			<table width="98%" border="0" cellpadding="0" cellspacing="0"
						background="../images/bg_body_title.jpg" class="list_border1">
						<tr>
							<td width="10">&nbsp;</td>
							<td>
								<table border="0" cellspacing="0" cellpadding="0">
									<tr>
										<td><img src="../images/pic_title_1.jpg" name="imgL1"
											width="8" height="24" id="imgL1"></td>
										<td valign="bottom" class="text_12_border" nowrap="nowrap"
											style="cursor: hand;" id="tdTitle1">新增岗位</td>
										<td><img src="../images/pic_title_2.jpg" name="imgR1"
											width="8" height="24" id="imgR1"></td>
									</tr>
								</table>
							</td>
						</tr>
					</table>
			<table width="98%" border="0" cellpadding="0" cellspacing="0"
				class="list_border2">
				<tr>
					<td align="center" valign="top">
					<table width="98%" height="10" border="0" cellpadding="0"
						cellspacing="0">
						<tr>
							<td></td>
						</tr>
					</table>
					<TABLE class=list_border cellSpacing=0 cellPadding=0 width="98%"
						border=0>
						<TBODY>
							<TR>
								<TD class=list_td_gray width="140">岗位名称 ：</TD>
								<TD class=list_td_white_line><input name="stationName"
									type="text" class="INPUT2" height="20" onchange="checkStationName(this)"> <span
									class="text_darkred">*</span>
									&nbsp;<span id="errMsg" class="text_darkred"></span>
									<input type="hidden" id="isExist" value="">
									<input type="hidden" id="systemId" name="systemId" value="${systemId}">
									</TD>
							</TR>
							<TR>
								<TD class=list_td_gray width="140">岗位类型 ：</TD>
								<TD class=list_td_white_line>
								<select name="stationType">
								<option value="1">园区管理员</option>
								<option value="2">企业管理员</option>
								<option value="3">浏览者</option>
								</select>
									</TD>
							</TR>
<!-- 							<TR> -->
<!-- 								<TD class=list_td_gray height=30>业务系统 ：</TD> -->
<!-- 								<TD height=30 class=list_td_white_line><INPUT class=INPUT2 -->
<!-- 									type="text" id="systemName" name="systemName" readonly="true"><input -->
<!-- 									type="button" name="selectSystem" onclick="openService();" -->
<!-- 									value="请选择业务系统"> <INPUT type="hidden" id="systemId" -->
<!-- 									name="systemId"><span class="text_darkred">*</span></TD> -->
<!-- 							</TR> -->
							<TR>
								<TD class=list_td_gray height=30>设置权限 ：</TD>
								<TD class=list_td_white_line width="88%"><textarea
									id="roleName" name="roleName" class="input_textarea"
									readonly="true"></textarea> <input type="button"
									name="chooseRole" onclick="openwin();" value="选择权限"> <INPUT
									type="hidden" name="roleId" id="roleId"><span
									class="text_darkred">*</span></TD>
							</TR>
							<TR>
								<TD class=list_td_gray height=30>岗位描述 ：</TD>
								<TD height=30 class=list_td_white_line><textarea
									id="stationDesc" name="stationDesc"></textarea></TD>
							</TR>
						</TBODY>
					</TABLE>
					<table width="98%" height="42" border="0" cellpadding="0"
						cellspacing="0">
						<tr>
							<td width="40%" align="center"><input name="Submit2"
								type="submit" class="button_normal" onclick="checkStationName(document.getElementById('stationName'))" value="完  成">
							&nbsp;&nbsp; <input name="Submit3" type="button"
								class="button_normal" value="返  回" onclick="window.location.href='../station/queryStation.html'" ></td>
						</tr>
					</table>
					</td>
				</tr>
			</table>
			<table width="98%" height="5" border="0" cellpadding="0"
				cellspacing="0">
				<tr>
					<td></td>
				</tr>
			</table>
			</TD>
		</TR>
	</TBODY>
</TABLE>
</FORM>
</BODY>
</HTML>
